﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Controls;

namespace InteractiveKidsShow
{
    class GestureDecisionPart : StoryPart
    {
        public int vidLength;
        public EnumKinectGestures.Gestures gestureDesired;
        public bool gestureWasDone;
        public Uri vidIfDone;
        public Uri vidIfNotDone;
        public bool hasVidPlayed;
        public bool hasSecondVidPlayed;

        public GestureDecisionPart(Uri requestVid, int requestVidLength, EnumKinectGestures.Gestures gesture, Uri done, Uri not)
        {
            vid = requestVid;
            gestureDesired = gesture;
            vidIfDone = done;
            vidIfNotDone = not;
            hasVidPlayed = false;
            hasSecondVidPlayed = false;
            gestureWasDone = false;
            vidLength = requestVidLength;
        }


        public void Play(ref MediaElement mediaPlayer, ref Kinect kinectObject)
        {
            if (!hasVidPlayed) // if the first vid (request) hasn't played, play that and make the request
            {
                mediaPlayer.Source = vid;
                mediaPlayer.Play();
                hasVidPlayed = true;
                kinectObject.requestGesture(gestureDesired, vidLength);
            }
            else if (gestureWasDone) // else if it has and they said the right word
            {
                hasSecondVidPlayed = true;
                mediaPlayer.Source = vidIfDone;
                mediaPlayer.Play();
            }
            else // otherwise it has but they didn't say the right word
            {
                    hasSecondVidPlayed = true;
                    mediaPlayer.Source = vidIfNotDone;
                    mediaPlayer.Play();
            }

        }
    }
}
